package com.example.learn_250821.code;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/prop")
@RestController
public class PropertiesController {

    @Value("${my.key}")
    private String myKey;

    @RequestMapping("/readValue")
    public String readValue() {
        return "readValue：从配置文件中读取配置信息：" + myKey;
    }

    @PostConstruct // 该注解表示在类加载阶段就会执行该方法
    public void readValue2() {
        System.out.println(("readValue2：从配置文件中读取配置信息：" + myKey));
    }

    public static void main(String[] args) {

    }
}